package storagex

import "fmt"

type Storage interface {
	Ticket() string
	TicketWithOverride(remoteKey string) string
	UploadFile(remoteKey, localFile string, override bool) (string, error)
	UploadBytes(remoteKey string, fBytes []byte, override bool) (string, error)
	UploadBigFile(remoteKey, localFile string, override bool) (string, error)
	Stat(remoteKey string) (*FileInfo, error)
	Delete(remoteKey string) error
	Move(srcKey, destKey string, force bool) error
	Copy(srcKey, destKey string, force bool) error
	MakePublicKey(remoteKey string) string
	MakePrivateKey(remoteKey string, expires int64) string
	List(dir, marker string, limit int) ([]FileInfo, string, error)
}

func NewStorage(cfg Config) (Storage, error) {
	switch cfg.Adapter {
	case "qiniu":
		return NewKodoStorage(cfg), nil
	}
	return nil, fmt.Errorf("没有找到对应的adapter: %s", cfg.Adapter)
}
